package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.KDRecovePaper;

/**
 * 
 * @author 
 *
 */
@DAO
public interface KDRecovePaperDAO{
	
	@SQL("SELECT * FROM KDRecovePaper WHERE deleteFlag=1 #if(:t.phone!=''){ and phone like '%##(:t.phone)%' } "
			+ "#if(:t.area!=null){ and area =:t.area } "
			+ "#if(:t.street!=null){ and street =:t.street } "
			+ "#if(:t.address!=''){ and address like '%##(:t.address)%' } "
			+ "ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<KDRecovePaper> query(@SQLParam("t") KDRecovePaper kDRecovePaper);
	
	@SQL("SELECT count(*) FROM KDRecovePaper WHERE deleteFlag=1 #if(:t.phone!=''){ and phone like '%##(:t.phone)%' } "
			+ "#if(:t.area!=null){ and area =:t.area } "
			+ "#if(:t.street!=null){ and street =:t.street } "
			+ "#if(:t.address!=''){ and address like '%##(:t.address)%' } ")
    int querySzie(@SQLParam("t") KDRecovePaper kDRecovePaper);
    
    @SQL("select * from KDRecovePaper where id=:1")
    KDRecovePaper queryById(int id);
    
    @SQL("UPDATE KDRecovePaper SET memo=:2 WHERE id=:1")
    void updateMemoById(int id,String memo);
    
    @SQL("UPDATE KDRecovePaper SET status=1 WHERE id=:1")
    void updateStatusById(int id);
    
    @SQL("UPDATE KDRecovePaper SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
    
    //导出数据
    @SQL("select id,link,phone,city,area,street,address,weight,descs,status,memo,deleteFlag,createAT,updateAT from KDRecovePaper where deleteFlag=1 #if(:start!=''){ and createAT>=:start } #if(:end!=''){ and createAT<=:end } order by id")
    List<Map> output(@SQLParam("start")String start, @SQLParam("end")String end);
}